package wtws.message;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import wtws.message.interf.TdwrProdMessage;

public class UnknownMessage implements TdwrProdMessage {

	private static final long serialVersionUID = 1L;
	private byte[] byteArray;
	private static String title = "Unknown Message";

	public UnknownMessage(byte[] byteArray) {
		this.byteArray = byteArray;
	}

	public UnknownMessage(File file) {
		new Decoder().decode(file);
	}

	@Override
	public byte[] toByteArray() {
		return this.byteArray;
	}

	@Override
	public String getMessageTitle() {
		return title;
	}

	public class Decoder {
		byte[] arr = null;

		public void decode(File file) {
			try {
				FileInputStream fis = new FileInputStream(file);
				arr = new byte[(int) file.length()];

				fis.read(arr);

				fis.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			byteArray = arr;
		}

	}

	public int getId() {
		return -99;
	}
}
